/*
 * Created: 2022-09-17 12:23:12
 * Author : 涛涛涛
 */

import React, { ComponentType, FC } from 'react';
import { View, Text, Input, InputProps } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { IProps as JYInputProps } from '../JYInput';
export interface IProps extends JYInputProps {
    setIsFocus: React.Dispatch<React.SetStateAction<boolean>>;
}
const InnerInput = React.forwardRef(function (props: IProps, inputRef: React.ForwardedRef<ComponentType<InputProps>>) {
    const { className, style, setIsFocus, onChange, onFocus, onBlur, ...others } = props;
    const localClassName = useClassName('InnerInput', className);
    return (
        <Input
            {...others}
            className={localClassName}
            style={style}
            ref={inputRef}
            type="text"
            onInput={(event) => {
                onChange(event.detail.value);
            }}
            onFocus={(event) => {
                setIsFocus(true);
                if (onFocus) onFocus(event.detail.value);
            }}
            onBlur={(event) => {
                setIsFocus(false);
                if (onBlur) onBlur(event.detail.value);
            }}
        />
    );
});
InnerInput.defaultProps = {} as Partial<IProps>;
export default React.memo(InnerInput as FC<IProps>);
